﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MixScript.BLL.FI;

namespace MixScriptWeb.Accounting.ReportObject
{
    public partial class frmTransportationCost : cCommonWeb, IMIxCommon
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { LoadData(); }
        }
        public bool isvalid()
        {
            return true;
        }

        private void LoadData()
        {
            for (int i = 0; i < ddlPeriod.Items.Count; i++)
            {
                ddlPeriod.Items[i].Text = String.Format(ddlPeriod.Items[i].Text, DateTime.Now.Year.ToString());
            }
            FillDropDownList(ddlCurrency, "mst_currency", "currency", "currency", true);

            rptManagementCosts mc = new rptManagementCosts();
            DataTable dt = new DataTable();
            dt = mc.management();
            gvList.DataSource = dt;
            gvList.DataBind();
        }

        protected void rbGlobal_CheckedChanges(Object sender, EventArgs e)
        {
            rptManagementCosts mc = new rptManagementCosts();
            DataTable dt = new DataTable();
            dt = mc.management();
            gvList.DataSource = dt;
            gvList.DataBind();

        }
        protected void chkAllHeader_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chkAll = new CheckBox();
            CheckBox chk;
            chkAll = (CheckBox)gvList.HeaderRow.Cells[0].FindControl("chkAllHeader");
            for (int i = 0; i < gvList.Rows.Count; i++)
            {
                chk = new CheckBox();
                chk = (CheckBox)gvList.Rows[i].Cells[0].FindControl("chkAll");
                chk.Checked = chkAll.Checked;

            }

        }

        protected void btnSubmit_Click(Object sender, EventArgs e)
        {


            String param = "";
            for (int i = 0; i < gvList.Rows.Count; i++)
            {
                CheckBox chk = new CheckBox();
                chk = (CheckBox)gvList.Rows[i].Cells[0].FindControl("chkAll");
                if (chk.Checked)
                {
                    if (param == "")
                        param = gvList.Rows[i].Cells[1].Text.TrimEnd();
                    else
                        param = param + "," + gvList.Rows[i].Cells[1].Text.TrimEnd();
                }
            }
            param = "";
            Session["param"] = param;
            Session["sCurr"] = ddlCurrency.SelectedItem.Value;
            Session["period"] = ddlPeriod.SelectedItem.Value;
            Session["periodName"] = ddlPeriod.SelectedItem.Text;

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW",
                "window.open( '/Accounting/ReportObject/TransportationCost.aspx', null, '' );", true);



        }

    }
}